<template>
  <div class="app-main">
    <div>
      请求demo 数据{{table1}}
    </div>
    <div>
      store 数据 {{$store.getters.obj1}}
    </div>

    我是demo
  </div>
</template>

<script>
import { getDemoTable1byId } from "@/api/demo";
export default {
  name: "demo",
  data() {
    return {
      table1: null,
    };
  },
  // 生命周期函数
  mounted() {
    this.getDemoTable1(1);
    // 调用 store mutatuin
    this.$store.dispatch('demo/SET_OBJ1', '123');

    this.$store.dispatch('demo/changeObj1', '1234');
  },
  // 方法
  methods: {
    getDemoTable1(id) {
      getDemoTable1byId(id).then((res) => {
        this.table1 = res;
      });
    },
  },
};
</script>

<style scoped></style>
